package com.ruoyi.project.module.yzx.jishi.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.project.domain.YqgInformationRoom;
import com.ruoyi.project.service.IYqgInformationRoomService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 房间基础信息Controller
 *
 * @author dr
 * @date 2023-04-17
 */
@RestController
@RequestMapping("/yzx/jishi/room")
public class YzxInformationRoomController extends BaseController
{
    @Autowired
    private IYqgInformationRoomService yqgInformationRoomService;

    /**
     * 查询房间基础信息列表
     */

    @GetMapping("/list")
    public TableDataInfo list(YqgInformationRoom yqgInformationRoom)
    {
        startPage();
        List<YqgInformationRoom> list = yqgInformationRoomService.selectYqgInformationRoomList(yqgInformationRoom);
        return getDataTable(list);
    }

    /**
     * 导出房间基础信息列表
     */

    @Log(title = "房间基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqgInformationRoom yqgInformationRoom)
    {
        List<YqgInformationRoom> list = yqgInformationRoomService.selectYqgInformationRoomList(yqgInformationRoom);
        ExcelUtil<YqgInformationRoom> util = new ExcelUtil<YqgInformationRoom>(YqgInformationRoom.class);
        util.exportExcel(response, list, "房间基础信息数据");
    }

    /**
     * 获取房间基础信息详细信息
     */

    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(yqgInformationRoomService.selectYqgInformationRoomByID(ID));
    }

    /**
     * 新增房间基础信息
     */

    @Log(title = "房间基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqgInformationRoom yqgInformationRoom)
    {
        return toAjax(yqgInformationRoomService.insertYqgInformationRoom(yqgInformationRoom));
    }

    /**
     * 修改房间基础信息
     */

    @Log(title = "房间基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqgInformationRoom yqgInformationRoom)
    {
        return toAjax(yqgInformationRoomService.updateYqgInformationRoom(yqgInformationRoom));
    }

    /**
     * 删除房间基础信息
     */

    @Log(title = "房间基础信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(yqgInformationRoomService.deleteYqgInformationRoomByIDs(IDs));
    }
}
